home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DBPCXL15.ARJ / DEMOS.ARJ / SHOWPAL.C < prev    next >
Text File  |  1992-01-26  |  2KB  |  69 lines

  1. /*  showpal.c */
  2.  
  3. #include <stdio.h>
  4. #include "vidlib.h"
  5. #include "pcxlib.h"
  6.  
  7. PCXF *pf1;
  8. void palette_check(void);
  9. char s[100];
  10. char name[80];
  11.  
  12. void main(int argc, char *argv[])
  13. {
  14.     int i,c;
  15.  
  16.     sprintf(s,"PCXLIB v%s Showpal     by Dave Boynton\n", PCXLIB_VERSION);
  17.  
  18.     if (argc < 2) {
  19.        puts(s);
  20.        printf("You must specify an input .pcx file.\n");
  21.        exit(1);
  22.     }
  23.     strncpy(name,argv[1],79); name[79]='0';
  24.  
  25.    /* Open debugging file */
  26.    #ifdef DEBUG
  27.    Start_pcxdebug("showpal.dbg");            /* start debugging */
  28.    fprintf(pcxdebug,"\nMAIN: arguments are: 0=%s 1=%s\n", argv[0], name);
  29.    fprintf(pcxdebug,"   sizeof(PCXF)=%u %xh, sizeof(PCXH)=%u %xh\n",
  30.                     sizeof(PCXF), sizeof(PCXF), sizeof(PCXH), sizeof(PCXH));
  31.    #endif
  32.    /* Open pcx file */
  33.    pf1=fopenPCXr(name); /* also reads header */
  34.    if (pf1->type != PCX256colors ) {
  35.       printf("Wrong pcx file, expected a 256 color file.\n");
  36.       exit(1);
  37.    }
  38.    Vinit();
  39.  
  40.    VGAmode(0x13, pf1->palette);
  41.    palette_check();
  42.    Vgotoxy(0,0);
  43.    putstty(s,0x1f);
  44.    Vgotoxy(0,1);
  45.    name[40]='0'; /* no more than 40 characters in a mode 0x13 line */
  46.    putstty(name,0x1f);
  47.    getch();
  48.  
  49.    Vclose();
  50.    if (pcxdebug) fprintf(pcxdebug,"PCXerror=%i\n", PCXerror);
  51.    fclosePCX(pf1);
  52.    Close_pcxdebug();
  53.    exit(0);
  54. }
  55.  
  56. void palette_check(void)
  57. {
  58.    int i,j,c;
  59.    Vfill256(0,0,320,200,0); /* clear screen */
  60.    for (i=c=0; i<16; i++) {
  61.        for (j=0; j<16; j++) {
  62.            Vfill256(j*20,i*11+21,19,10,c);
  63.            c++;
  64.        }
  65.    }
  66. }
  67.  
  68. 
  69.